package watercups.operators;

import watercups.states.WaterCupState;
import templates.Operator;

public class Empty_1to2 implements Operator<WaterCupState>{
	
	public int getOperatorNumber(){ 
		return 1;
	}

	public WaterCupState execute(WaterCupState s) {
		
		
		
		int cantitateCeTrebuieTransferata= 4 - s.getCapacity2();	
		int cantitateTransferata;
		if(cantitateCeTrebuieTransferata <s.getCapacity1())
			cantitateTransferata= cantitateCeTrebuieTransferata;
		else
			cantitateTransferata=s.getCapacity1();
		s.setCapacity1(s.getCapacity1() - cantitateTransferata);
		s.setCapacity2(s.getCapacity2() + cantitateTransferata);
		return s;
//		return new WaterCupState(0,s.getCapacity2());	
		
	}

	public boolean available(WaterCupState s) {
		
		if ( (s.getCapacity1()>0 && s.getCapacity1()<=3) && s.getCapacity2()<4)
			return true;
		else
			return false;
		

		
	}

	public String toString() {
		return "Emptying from 1 cup to 2 cup";
	}
}
